import "antd/es/skeleton/style";
import _Skeleton from "antd/es/skeleton";
import "antd/es/tag/style";
import _Tag from "antd/es/tag";
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
import React, { useState, useEffect } from 'react';
import { SearchTree } from '@szzj/ds';
import { deptTreeData } from "../data";
import { EditOutlined } from '@ant-design/icons';
import { jsx as _jsx } from "react/jsx-runtime";
import { jsxs as _jsxs } from "react/jsx-runtime";
export default (function () {
  var _treeData$;
  var _useState = useState([]),
    _useState2 = _slicedToArray(_useState, 2),
    treeData = _useState2[0],
    setTreeData = _useState2[1];
  var _useState3 = useState(false),
    _useState4 = _slicedToArray(_useState3, 2),
    loading = _useState4[0],
    setLoading = _useState4[1];
  var _useState5 = useState(false),
    _useState6 = _slicedToArray(_useState5, 2),
    editvisible = _useState6[0],
    setEditvisible = _useState6[1];
  useEffect(function () {
    setLoading(true);
    setTimeout(function () {
      deptTreeData[0].children[1].title = '超长超长超长超长超长超长超长超长超长超长';
      deptTreeData[0].children[1].more = /*#__PURE__*/_jsx(_Tag, {
        children: "\u6211\u662F\u6807\u7B7E"
      });
      setTreeData(deptTreeData);
      setLoading(false);
    }, 3000);
  }, []);
  console.log('editvisible', editvisible);
  var renderOp = function renderOp(node) {
    var handleOp = function handleOp(e) {
      e.stopPropagation();
      console.log(node);
      console.log(e.target);
      setEditvisible(false);
    };
    var items = [{
      key: '1',
      label: '编辑',
      onClick: function onClick(e) {}
    }, {
      key: '2',
      label: '新增子组织'
    }, {
      key: '3',
      label: '删除'
    }];
    //   return <Dropdown menu={{ items }} >
    //   <span onClick={handleOp}><EditOutlined /></span>
    // </Dropdown>
    return /*#__PURE__*/_jsx("span", {
      onClick: handleOp,
      children: /*#__PURE__*/_jsx(EditOutlined, {})
    });
  };
  var expandedKeys = treeData.length === 1 ? [treeData[0].key] : [];
  var defaultSelectedKeys = [treeData === null || treeData === void 0 ? void 0 : (_treeData$ = treeData[0]) === null || _treeData$ === void 0 ? void 0 : _treeData$.key];
  return /*#__PURE__*/_jsxs("div", {
    style: {
      display: 'flex',
      height: 500
    },
    children: [/*#__PURE__*/_jsx("div", {
      style: {
        width: 350
      },
      children: /*#__PURE__*/_jsx(SearchTree, {
        title: "\u90E8\u95E8\u9009\u62E9",
        treeData: treeData,
        loading: loading,
        showTitle: true,
        defaultExpandedKeys: expandedKeys,
        showFiltered: true,
        showReset: true,
        renderOp: renderOp,
        defaultSelectedKeys: defaultSelectedKeys
        // selectable={false}
        // onSelect={(e) => {console.log(e)}}
        // titleRender={() => {return <span>节点</span>}}
        ,
        onSelect: function onSelect(value, s) {
          console.log('选中节点', value);
          console.log(s && s.node.deptPath);
        }
      })
    }), /*#__PURE__*/_jsx("div", {
      style: {
        flex: 1,
        paddingLeft: 40
      },
      children: /*#__PURE__*/_jsx(_Skeleton, {
        paragraph: {
          rows: 10
        }
      })
    })]
  });
});